package leecode

import (
	"strings"
)

func ReplaceSpaces(S string, length int) string {
	arr := strings.Split(S, "")
	str := make([]string, 0, length)
	for _, value := range arr {
		if value == " " {
			str = append(str, "%20")
		} else {
			str = append(str, value)
		}
	}
	return strings.Join(str[:length], "")
}
